package org.one.stone.soup.grfxML.plugin.image;

import java.awt.Color;

import org.one.stone.soup.grfxML.DataColor;
import org.one.stone.soup.grfxML.DataImage;
import org.one.stone.soup.grfxML.DataPoint;
import org.one.stone.soup.grfxML.GeometryImage;
import org.one.stone.soup.grfxML.GrfxMLEngine;
import org.one.stone.soup.grfxML.plugin.SimplePlugin;
import org.one.stone.soup.grfxML.plugin.grfxMLCaster;
import org.one.stone.soup.mjdb.data.field.DataLinker;
import org.one.stone.soup.mjdb.data.field.Field;

public class Block extends SimplePlugin {

	public static final int ARG_IMAGE = 0;

	public static final int ARG_SIZE = 1;

	public static final int ARG_COLOR = 2;

	DataColor color = new DataColor();
	DataImage image = new DataImage();
	DataPoint size = new DataPoint();

/**
 * SimpleImageButton constructor comment.
 */
public Block (GrfxMLEngine engine){
	super(engine);
}
/**
 * initialize method comment.
 */
public void initialize()
{
}
/**
 * process method comment.
 */
public void process()
{
	Color newColor = new Color(
		color.getValueX(),
		color.getValueY(),
		color.getValueZ()
	);

	((GeometryImage)image.getGeometry(getEngine())).setImage(
				org.one.stone.soup.grfx.ImageFactory.createImage(
						newColor,
						size.getValueX(),
						size.getValueY()
					)
			);
}
/**
 * register method comment.
 */
public void register(DataLinker store)
{
	color = grfxMLCaster.cast(color,getArg(color,ARG_COLOR,store));

	image = grfxMLCaster.cast(image,getArg(image,ARG_IMAGE,store));

	size = grfxMLCaster.cast(size,getArg(size,ARG_SIZE,store));

}
/**
 * replace method comment.
 */
public void replace(Field oldObj, Field newObj)
{
	image = grfxMLCaster.replace(image,oldObj,newObj);
	size = grfxMLCaster.replace(size,oldObj,newObj);
	color = grfxMLCaster.replace(color,oldObj,newObj);
}
/**
 * stop method comment.
 */
public void stop() {}
}
